/****************************************************
*	OSMF Edge Media Player version 1.2.0
* 
*	Author: Emanuele Manco
* 	E-Mail: hello@flashedge.net
*	Web: http://activeden.net/user/flashedge
*  
*****************************************************/

package net.flashedge.utils 
{
	
	public class Setup
	{
		public var scaleMode:String;

		public var autoPlay:String;
		public var loopEnabled:String;
		public var shuffleEnabled:String;
		public var fluidMode:String;
		public var videoPath:Number;
		public var bufferTime:Number;
		
		public var autoQuality:String;
		public var indexLevel:Number;
		
		public var playerWidth:Number;
		public var playerHeight:Number;
		public var playerX:Number;
		public var playerY:Number;
		
		public var playerBackgroundAlpha:Number;
		public var playerBackgroundColor:uint;
		
		public var playBtnWidth:Number;
		public var playBtnHeight:Number;
		public var playBtnRadius:Number;
		
		public var headerEnabled:String;
		
		public var titleSize:Number;
		public var titleColor:uint;
		public var titleX:Number;
		public var titleY:Number;
		
		public var infoButtonEnabled:String;
		public var infoButtonLabel:String;
		
		public var playlistButtonEnabled:String;
		public var playlistButtonLabel:String;
		
		public var settingsButtonEnabled:String;
		public var settingsButtonLabel:String;
		
		public var tweetButtonEnabled:String;
		public var tweetButtonLabel:String;
		
		public var likeButtonEnabled:String;
		public var likeButtonLabel:String;
		
		public var controlsRadius:Number;
		public var controlsPadding:Number;
		public var controlsOffset:Number;
		
		public var seekbarHeight:Number;
		public var seekbarRadius:Number;
		public var seekbarProgressColor:uint;
		public var seekbarCacheColor:uint;
		public var seekbarTrackColor:uint;
		public var seekbarPadding:Number;
		
		public var volumebarHeight:Number;
		public var volumebarRadius:Number;
		public var volumebarTrackColor:Number;
		public var volumebarLevelColor:Number;
		public var volumebarPadding:Number;
		
		public var volumeLevel:Number;
		
		public var tooltipBgColor:uint;
		public var tooltipTextColor:uint;
		
		public var hideDelay:Number;
		
		public var pluginEnabled:String;
		public var plugins:Array;
		
		public var descriptionWidth:Number;
		public var descriptionHeight:Number;
		public var descriptionThumbWidth:Number;
		public var descriptionThumbHeight:Number;
		public var descriptionSize:Number;
		public var descriptionKerning:Number;
		public var descriptionColor:uint;
		public var descriptionPadding:Number;
		public var descriptionRulerColor:uint;
		public var descriptionTrackColor:uint;
		public var descriptionScrollCorner:Number;
		public var descriptionScrollWidth:Number;
		
		public var loopEnabledLabel:String;
		public var loopDisabledLabel:String;
	
		public var shuffleEnabledLabel:String;
		public var shuffleDisabledLabel:String;

		public var scaleNoneLabel:String;
		public var scaleLetterboxLabel:String;
		public var scaleStretchLabel:String;
		public var scaleZoomLabel:String;
		
		public var playlistWidth:Number;
		public var playlistThumbWidth:Number;
		public var playlistThumbHeight:Number;
		public var playlistRadius:Number;
		public var playlistSpacing:Number;
		public var playlistPadding:Number;
		public var playlistThumbNum:Number;
		
		public var playlistThumbBrightness:Number;
		public var playlistThumbContrast:Number;
		public var playlistThumbSaturation:Number;
		public var playlistThumbScale:Number;
		
		public var playlistTextSize:Number;
		public var playlistTextRows:Number;
		public var playlistTextKerning:Number;
		public var playlistTextColor:uint;
		
		public var playlistAtEnding:String;
		
		public var contextMenuLabel:String;
		public var contextMenuLink:String;
		
		public var data:XML;
		
		public var toolbarBtns:Array = new Array();
		
		public function Setup() 
		{
			init();
		}
		
		private function init():void
		{
			autoPlay = "true";
			fluidMode = "false";
			bufferTime = 5;
			scaleMode = "letterbox";
			
			playerWidth = 640;
			playerHeight = 360;
			playerX = 0;
			playerY = 0;
			
			playerBackgroundAlpha = 1;
			playerBackgroundColor = 0x000000;
			
			playBtnWidth = 70;
			playBtnHeight = 70;
			playBtnRadius = 12;
			
			autoQuality = "true";
			indexLevel = 0;
			
			headerEnabled = "false";
			
			titleColor = titleColor;
			titleSize = titleSize;
			titleX = titleX;
			titleY = titleY;
			
			infoButtonEnabled = "true";
			infoButtonLabel = "Information";
			
			playlistButtonEnabled = "true";
			playlistButtonLabel = "Playlist";
			
			settingsButtonEnabled = "true";
			settingsButtonLabel = "Settings";
			
			tweetButtonEnabled = "true";
			tweetButtonLabel = "Tweet";
			
			likeButtonEnabled = "true";
			likeButtonLabel = "Like";
			
			controlsRadius = 10;
			controlsPadding = 0;
			controlsOffset = 0;
			
			seekbarHeight = 4;
			seekbarRadius = 8;
			
			seekbarProgressColor = 0xE2E2E2;
			seekbarCacheColor = 0x444444;
			seekbarTrackColor = 0x000000
			seekbarPadding = 3;
			
			tooltipBgColor = 0x000000;
			tooltipTextColor = 0xFFFFFF;
			
			volumebarHeight = 2;
			volumebarRadius = 4;
			volumebarTrackColor = 0x000000;
			volumebarLevelColor = 0xFFFFFF;
			volumebarPadding = 3;
			volumeLevel = 0;
			
			hideDelay = 6;
			
			loopEnabledLabel = "Loop is ON";
			loopDisabledLabel = "Loop is OFF";
			
			shuffleEnabledLabel = "Shuffle is ON";
			shuffleDisabledLabel = "Shuffle is OFF";

			scaleNoneLabel = "Original";
			scaleLetterboxLabel = "Letterbox";
			scaleStretchLabel = "Stretch";
			scaleZoomLabel = "Zoom";
			
			contextMenuLabel = "OSMF EDGE Media Player";
			contextMenuLink = "http://activeden.net/user/flashedge?ref=flashedge";
		}
		
		public function parse(xmldata:XML):void {
			data = xmldata;
			bufferTime = xmldata.@bufferTime;
			
			scaleMode = xmldata.@scaleMode;
			
			autoPlay = xmldata.@autoPlay;
			loopEnabled = xmldata.@loopEnabled;
			shuffleEnabled = xmldata.@shuffleEnabled;
			fluidMode = xmldata.@fluidMode;
			
			playerWidth = xmldata.@playerWidth;
			playerHeight = xmldata.@playerHeight;
			playerX = xmldata.@playerX;
			playerY = xmldata.@playerY;
			
			autoQuality = xmldata.@autoQuality;
			indexLevel = xmldata.@indexLevel;
			
			playerBackgroundAlpha = xmldata.@playerBgAlpha;
			playerBackgroundColor = xmldata.@playerBgColor;
			
			playBtnWidth = xmldata.@playBtnWidth;
			playBtnHeight = xmldata.@playBtnHeight;
			playBtnRadius = xmldata.@playBtnRadius;
			
			headerEnabled = xmldata.@headerEnabled;
			
			titleColor = xmldata.@titleColor;
			titleSize = xmldata.@titleSize;
			titleX = xmldata.@titleX;
			titleY = xmldata.@titleY;
			
			infoButtonEnabled =  xmldata.@infoButtonEnabled;
			infoButtonLabel = xmldata.@infoButtonLabel;
			
			playlistButtonEnabled =  xmldata.@playlistButtonEnabled;
			playlistButtonLabel = xmldata.@playlistButtonLabel;
			
			settingsButtonEnabled =  xmldata.@settingsButtonEnabled;
			settingsButtonLabel = xmldata.@settingsButtonLabel;
			
			tweetButtonEnabled =  xmldata.@tweetButtonEnabled;
			tweetButtonLabel = xmldata.@tweetButtonLabel;
			
			likeButtonEnabled =  xmldata.@likeButtonEnabled;
			likeButtonLabel = xmldata.@likeButtonLabel;
			
			controlsRadius = xmldata.@controlsRadius;
			controlsOffset = xmldata.@controlsOffset;
			controlsPadding = xmldata.@controlsPadding;
			
			seekbarHeight = xmldata.@seekbarHeight;
			seekbarRadius = xmldata.@seekbarRadius;
			
			seekbarProgressColor = xmldata.@seekbarProgressColor;
			seekbarCacheColor = xmldata.@seekbarCacheColor;
			seekbarTrackColor = xmldata.@seekbarTrackColor;
			seekbarPadding = xmldata.@seekbarPadding;
			
			tooltipBgColor = xmldata.@tooltipBgColor;
			tooltipTextColor = xmldata.@tooltipTextColor;
			
			volumebarHeight = xmldata.@volumebarHeight;
			volumebarRadius = xmldata.@volumebarRadius;
			volumebarTrackColor = xmldata.@volumebarTrackColor;
			volumebarLevelColor = xmldata.@volumebarLevelColor;
			volumebarPadding = xmldata.@volumebarPadding;
			volumeLevel = xmldata.@volumeLevel;
			
			descriptionColor = xmldata.@descriptionColor;
			descriptionKerning = xmldata.@descriptionKerning;
			descriptionPadding = xmldata.@descriptionPadding;
			descriptionRulerColor = xmldata.@descriptionRulerColor;
			descriptionScrollCorner = xmldata.@descriptionScrollCorner;
			descriptionScrollWidth = xmldata.@descriptionScrollWidth;
			descriptionSize = xmldata.@descriptionSize;
			descriptionTrackColor = xmldata.@descriptionTrackColor;
			descriptionWidth = xmldata.@descriptionWidth;
			descriptionHeight = xmldata.@descriptionHeight;
			descriptionThumbWidth = xmldata.@descriptionThumbWidth;
			descriptionThumbHeight = xmldata.@descriptionThumbHeight;
			
			loopEnabledLabel = xmldata.@loopEnabledLabel;
			loopDisabledLabel = xmldata.@loopDisabledLabel;
	
			shuffleEnabledLabel = xmldata.@shuffleEnabledLabel;
			shuffleDisabledLabel = xmldata.@shuffleDisabledLabel;
	
			scaleNoneLabel = xmldata.@scaleNoneLabel;
			scaleLetterboxLabel = xmldata.@scaleLetterboxLabel;
			scaleStretchLabel = xmldata.@scaleStretchLabel;
			scaleZoomLabel = xmldata.@scaleZoomLabel
			
			hideDelay = xmldata.@hideDelay;
			
			playlistWidth = xmldata.@playlistWidth;
			playlistThumbWidth = xmldata.@playlistThumbWidth;
			playlistThumbHeight = xmldata.@playlistThumbHeight;
			playlistSpacing = xmldata.@playlistSpacing;
			playlistPadding = xmldata.@playlistPadding;
			playlistRadius = xmldata.@playlistRadius;
			playlistThumbNum = xmldata.@playlistThumbNum;
			
			playlistTextColor = xmldata.@playlistTextColor;
			playlistTextRows = xmldata.@playlistTextRows;
			playlistTextKerning = xmldata.@playlistTextKerning;
			playlistTextSize = xmldata.@playlistTextSize;
			
			playlistThumbContrast = xmldata.@playlistThumbContrast;
			playlistThumbBrightness = xmldata.@playlistThumbBrightness;
			playlistThumbSaturation = xmldata.@playlistThumbSaturation;
			playlistThumbScale = xmldata.@playlistThumbScale;
			
			playlistAtEnding = xmldata.@playlistAtEnding;
			
			contextMenuLabel = xmldata.@contextMenuLabel;
			contextMenuLink = xmldata.@contextMenuLink;
			
			pluginEnabled = xmldata.plugins.@enabled;
			
			populatePlugins(xmldata);
			populateToolbar();
		}
		
		private function populatePlugins(xmldata:XML):void
		{
			plugins = new Array();
			
			for (var i:int = 0; i < xmldata.plugins.module.length(); i++) {
				
				plugins.push( {
							id: xmldata.plugins.module[i].@id,
							path: xmldata.plugins.module[i].@path
							});
			
			}
		}
		
		private function populateToolbar():void {
			toolbarBtns.push ( { name: "infoButton" , enabled: infoButtonEnabled , label: infoButtonLabel } );
			toolbarBtns.push ( { name: "playlistButton" , enabled: playlistButtonEnabled , label: playlistButtonLabel } );
			toolbarBtns.push ( { name: "settingsButton" , enabled: settingsButtonEnabled , label: settingsButtonLabel } );
			toolbarBtns.push ( { name: "tweetButton" , enabled: tweetButtonEnabled , label: tweetButtonLabel } );
			toolbarBtns.push ( { name: "likeButton" , enabled: likeButtonEnabled , label: likeButtonLabel } );
		}
		
	}

}